package com.hospital.service.impl;

import com.hospital.dao.HospitalizedDao;
import com.hospital.dto.Hospitalized;
import com.hospital.service.intf.HospitalizedService;
import com.hospital.vo.PageBean;
import com.hospital.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class HospitalizedServiceImpl implements HospitalizedService {
    @Autowired
    private HospitalizedDao dao;

    public PageBean selectPage(Integer id, int page, int limit){
        int start=(page-1)*limit;

        return PageBean.ok(dao.selectCount(id),dao.selectPage(id,start,limit));
    }

    @Override
    public R add(Hospitalized hospitalized) {

            if (dao.add(hospitalized) > 0) {
                return R.ok();
            } else {
                return R.fail();
            }
    }

    @Override
    public R update(Hospitalized hospitalized) {
        if(dao.update(hospitalized)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public R delIds(int[] ids) {
        if(dao.delByIds(ids)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }
}
